define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'user/user/index',
                    add_url: 'user/user/add',
                    edit_url: 'user/user/edit',
                    del_url: 'user/user/del',
                    multi_url: 'user/user/multi',
                    table: 'user',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'uid',
                sortName: 'user.uid',
                columns: [
                    [
                        {type:'checkbox'},
			            {field: 'uid', title: 'UID', align: 'center',width:70},
			            {field: 'avatar', title: '头像', events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false},
			            {field: 'nickname', title: '昵称',align: 'center'},
			            // {field: 'business', title: '讲师',align: 'center',width:'6%'},
			            {field: 'user_type', title: '用户类型',width:'6%',align:'center',operate:false},
			            {field: 'phone', title: '手机号',align: 'center'},
			            {field: 'spread_uid_nickname', title: '推荐人',align: 'center',operate:false},
			            {field: 'now_money', title: '余额',align: 'center',operate:false},
			            {field: 'gold_num', title: Config.gold_name,align: 'center',operate:false},
			            // {field: 'levelType', title: '会员',align: 'center',width:'6%'},
			            // {field: 'member', title: '会员记录',templet:'#member',align: 'center',width:'7%'},
                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            },
        }
    };
    return Controller;
});